Repository navigation
refactor: 토큰을 httpOnly 쿠키와 메모리로 옮기고 페이지 보호 (#40) - #51
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
개요
액세스 토큰을 localStorage 대신 메모리에 두고, 리프레시 토큰은 서버가 주는 httpOnly 쿠키로 주고받는다. 로그인하지 않은 사람에게는 페이지를 그리기 전에 /login으로 보낸다. (tail-server#191 머지 기준)
closes #40
변경 사항
tokens.access)에만 둔다. localStorage 코드와shortcut:주석을 지웠다X-Client-Type: WEB,withCredentials를 보낸다. 재발급은 본문 없이 쿠키로 한다proxy.ts:signedIn쿠키가 없으면 /login으로 보낸다. /login,_next/, 점이 든 정적 파일은 제외refresh_token)는 Path가/api/v1/auth라 페이지 요청에는 오지 않는다. 그래서 로그인·재발급 때signedIn표시 쿠키를 따로 심고(14일), 로그아웃·재발급 실패 때 지운다 (lib/session.ts)api.test.ts를 고치고proxy.test.ts를 추가했다docs/deploy.md: tail-server#193(도메인·HTTPS) 기준으로 고쳤다. 웹 3001은 열지 않고, CORS·NEXT_PUBLIC_API_URL·소셜 로그인 리다이렉트 URI를https://<ADMIN_DOMAIN>·https://<API_DOMAIN>기준으로 적었다확인 방법
npm run lint,format:check,typecheck,npm test(28개) 통과참고
admin.<도메인>,api.<도메인>)여야 쿠키가 간다signedIn은 화면 이동용 힌트이고 실제 인증은 API가 한다. 만료는 서버 리프레시 만료(기본 14일)와 맞췄고, 서버 값을 바꾸면session.ts도 바꿔야 한다/login?error=expired로 이동한다